USE [Fisharoo]
GO
/****** Object:  Table [dbo].[AccountFiles]    Script Date: 06/23/2009 11:40:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AccountFiles](
	[AccountID] [int] NOT NULL,
	[FileID] [bigint] NOT NULL,
	[Timestamp] [timestamp] NOT NULL
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[AccountFolders]    Script Date: 06/23/2009 11:40:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AccountFolders](
	[AccountID] [int] NOT NULL,
	[FolderID] [bigint] NOT NULL,
	[Timestamp] [timestamp] NOT NULL
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[AccountPermissions]    Script Date: 06/23/2009 11:40:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AccountPermissions](
	[apid] [int] IDENTITY(1,1) NOT NULL,
	[AccountID] [int] NOT NULL,
	[PermissionID] [int] NOT NULL,
	[Timestamp] [timestamp] NOT NULL,
 CONSTRAINT [PK_AccountPermissions] PRIMARY KEY CLUSTERED 
(
	[apid] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Accounts]    Script Date: 06/23/2009 11:40:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Accounts](
	[AccountID] [int] IDENTITY(1,1) NOT NULL,
	[FirstName] [varchar](30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[LastName] [varchar](30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Email] [varchar](150) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[EmailVerified] [bit] NOT NULL CONSTRAINT [DF_Accounts_EmailVerified]  DEFAULT ((0)),
	[Zip] [varchar](15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Username] [varchar](30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Password] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[BirthDate] [smalldatetime] NULL,
	[CreateDate] [smalldatetime] NULL CONSTRAINT [DF_Accounts_CreateDate]  DEFAULT (getdate()),
	[LastUpdateDate] [smalldatetime] NULL,
	[Timestamp] [timestamp] NOT NULL,
	[TermID] [int] NOT NULL CONSTRAINT [DF_Accounts_TermsID]  DEFAULT ((0)),
	[AgreedToTermsDate] [smalldatetime] NULL CONSTRAINT [DF_Accounts_AgreedToTermsDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_Accounts] PRIMARY KEY CLUSTERED 
(
	[AccountID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Alerts]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Alerts](
	[AlertID] [bigint] IDENTITY(1,1) NOT NULL,
	[AccountID] [int] NOT NULL,
	[CreateDate] [datetime] NOT NULL CONSTRAINT [DF_Alerts_CreateDate]  DEFAULT (getdate()),
	[Timestamp] [timestamp] NOT NULL,
	[AlertTypeID] [int] NOT NULL,
	[IsHidden] [bit] NOT NULL CONSTRAINT [DF_Alerts_IsHidden]  DEFAULT ((0)),
	[Message] [varchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 CONSTRAINT [PK_Alerts] PRIMARY KEY CLUSTERED 
(
	[AlertID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[AlertTypes]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[AlertTypes](
	[AlertTypeID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 CONSTRAINT [PK_AlertTypes] PRIMARY KEY CLUSTERED 
(
	[AlertTypeID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Blogs]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Blogs](
	[BlogID] [bigint] IDENTITY(1,1) NOT NULL,
	[AccountID] [int] NOT NULL,
	[Title] [varchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Subject] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Post] [varchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL,
	[UpdateDate] [smalldatetime] NOT NULL,
	[IsPublished] [bit] NOT NULL CONSTRAINT [DF_Blogs_IsPublished]  DEFAULT ((1)),
	[PageName] [varchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 CONSTRAINT [PK_Blogs] PRIMARY KEY CLUSTERED 
(
	[BlogID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[BoardCategorys]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[BoardCategorys](
	[CategoryID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Subject] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[SortOrder] [int] NOT NULL,
	[Timestamp] [timestamp] NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL,
	[UpdateDate] [smalldatetime] NOT NULL,
	[ThreadCount] [int] NOT NULL,
	[PostCount] [int] NOT NULL,
	[LastPostDate] [smalldatetime] NOT NULL,
	[LastPostByAccountID] [int] NOT NULL,
	[LastPostByUsername] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[PageName] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 CONSTRAINT [PK_BoardCategorys] PRIMARY KEY CLUSTERED 
(
	[CategoryID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[BoardForums]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[BoardForums](
	[ForumID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Subject] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[ThreadCount] [bigint] NOT NULL,
	[PostCount] [bigint] NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL,
	[UpdateDate] [smalldatetime] NOT NULL,
	[LastPostDate] [smalldatetime] NOT NULL,
	[LastPostByAccountID] [int] NOT NULL,
	[LastPostByUsername] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Timestamp] [timestamp] NOT NULL,
	[CategoryID] [int] NOT NULL,
	[PageName] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 CONSTRAINT [PK_BoardForums] PRIMARY KEY CLUSTERED 
(
	[ForumID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[BoardPosts]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[BoardPosts](
	[PostID] [bigint] IDENTITY(1,1) NOT NULL,
	[IsThread] [bit] NOT NULL,
	[Name] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Post] [varchar](3000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL,
	[UpdateDate] [smalldatetime] NOT NULL,
	[AccountID] [int] NOT NULL,
	[Username] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[ReplyCount] [int] NOT NULL,
	[ReplyByUsername] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[ViewCount] [int] NOT NULL,
	[ForumID] [int] NOT NULL,
	[PageName] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[ThreadID] [bigint] NULL,
	[ReplyByAccountID] [int] NULL,
 CONSTRAINT [PK_BoardPosts] PRIMARY KEY CLUSTERED 
(
	[PostID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Comments]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Comments](
	[CommentID] [bigint] IDENTITY(1,1) NOT NULL,
	[Timestamp] [timestamp] NOT NULL,
	[Body] [varchar](2000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL,
	[CommentByAccountID] [int] NOT NULL,
	[CommentByUsername] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[SystemObjectID] [int] NOT NULL,
	[SystemObjectRecordID] [bigint] NOT NULL,
 CONSTRAINT [PK_Comments] PRIMARY KEY CLUSTERED 
(
	[CommentID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ContentFilters]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ContentFilters](
	[ContentFilterID] [int] IDENTITY(1,1) NOT NULL,
	[StringToFilter] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[ReplaceWith] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[AccountID] [int] NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL,
	[TimeStamp] [timestamp] NOT NULL,
 CONSTRAINT [PK_ContentFilters] PRIMARY KEY CLUSTERED 
(
	[ContentFilterID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Files]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Files](
	[FileID] [bigint] IDENTITY(1,1) NOT NULL,
	[FileSystemName] [uniqueidentifier] NOT NULL,
	[FileSystemFolderID] [int] NOT NULL,
	[FileName] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[FileTypeID] [int] NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL CONSTRAINT [DF_Files_CreateDate]  DEFAULT (getdate()),
	[AccountID] [int] NOT NULL,
	[IsPublicResource] [bit] NOT NULL,
	[DefaultFolderID] [bigint] NOT NULL,
	[Description] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Timestamp] [timestamp] NOT NULL,
	[Size] [bigint] NOT NULL,
 CONSTRAINT [PK_Files] PRIMARY KEY CLUSTERED 
(
	[FileID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[FileSystemFolders]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[FileSystemFolders](
	[FileSystemFolderID] [int] IDENTITY(1,1) NOT NULL,
	[Path] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Timestamp] [timestamp] NOT NULL,
 CONSTRAINT [PK_FileSystemFolders] PRIMARY KEY CLUSTERED 
(
	[FileSystemFolderID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[FileTypes]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[FileTypes](
	[FileTypeID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 CONSTRAINT [PK_FileTypes] PRIMARY KEY CLUSTERED 
(
	[FileTypeID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[FolderFiles]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[FolderFiles](
	[FolderID] [bigint] NOT NULL,
	[FileID] [bigint] NOT NULL,
	[AccountID] [int] NOT NULL,
	[CreateDate] [smalldatetime] NULL,
	[Timestamp] [timestamp] NOT NULL
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Folders]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Folders](
	[FolderID] [bigint] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[IsPublicResource] [bit] NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL CONSTRAINT [DF_Folders_CreateDate]  DEFAULT (getdate()),
	[AccountID] [int] NOT NULL,
	[Description] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Location] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Timestamp] [timestamp] NOT NULL,
	[FolderTypeID] [int] NULL,
 CONSTRAINT [PK_Folders] PRIMARY KEY CLUSTERED 
(
	[FolderID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[FolderTypes]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[FolderTypes](
	[FolderTypeID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 CONSTRAINT [PK_FolderTypes] PRIMARY KEY CLUSTERED 
(
	[FolderTypeID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[FriendInvitations]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[FriendInvitations](
	[InvitationID] [int] IDENTITY(1,1) NOT NULL,
	[AccountID] [int] NOT NULL,
	[Email] [varchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[GUID] [uniqueidentifier] NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL CONSTRAINT [DF_Invitations_CreateDate]  DEFAULT (getdate()),
	[BecameAccountID] [int] NOT NULL CONSTRAINT [DF_FriendInvitations_BecameAccountID]  DEFAULT ((0)),
	[Timestamp] [timestamp] NOT NULL,
 CONSTRAINT [PK_Invitations] PRIMARY KEY CLUSTERED 
(
	[InvitationID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Friends]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Friends](
	[FriendID] [int] IDENTITY(1,1) NOT NULL,
	[AccountID] [int] NOT NULL,
	[MyFriendsAccountID] [int] NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL CONSTRAINT [DF_Friends_CreateDate]  DEFAULT (getdate()),
	[Timestamp] [timestamp] NOT NULL,
 CONSTRAINT [PK_Friends] PRIMARY KEY CLUSTERED 
(
	[FriendID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[FriendshipDefinitions]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[FriendshipDefinitions](
	[FriendshipDefinitionID] [int] IDENTITY(1,1) NOT NULL,
	[FriendID] [int] NOT NULL,
	[FriendshipDefinitionTypeID] [int] NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL CONSTRAINT [DF_FriendshipDefinitions_CreateDate]  DEFAULT (getdate()),
	[Description] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[DateFrom] [smalldatetime] NULL,
	[DateTo] [smalldatetime] NULL,
	[OptionalText1] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[OptionalText2] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Approved] [bit] NOT NULL CONSTRAINT [DF_FriendshipDefinitions_Approved]  DEFAULT ((0)),
	[Timestamp] [timestamp] NOT NULL,
 CONSTRAINT [PK_FriendshipDefinitions] PRIMARY KEY CLUSTERED 
(
	[FriendshipDefinitionID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[FriendshipDefinitionTypes]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[FriendshipDefinitionTypes](
	[FriendshipDefinitionTypeID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 CONSTRAINT [PK_FriendshipDefinitionTypes] PRIMARY KEY CLUSTERED 
(
	[FriendshipDefinitionTypeID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Gags]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Gags](
	[GagID] [bigint] IDENTITY(1,1) NOT NULL,
	[AccountID] [int] NOT NULL,
	[AccountUsername] [varchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL,
	[TimeStamp] [timestamp] NOT NULL,
	[Reason] [varchar](1000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[GagUntilDate] [smalldatetime] NULL,
	[GaggedByAccountID] [int] NOT NULL,
 CONSTRAINT [PK_Gags] PRIMARY KEY CLUSTERED 
(
	[GagID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[GroupForums]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[GroupForums](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[GroupID] [int] NOT NULL,
	[ForumID] [int] NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL,
	[Timestamp] [timestamp] NOT NULL,
 CONSTRAINT [PK_GroupForums] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[GroupMembers]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[GroupMembers](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[GroupID] [int] NOT NULL,
	[AccountID] [int] NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL,
	[Timestamp] [timestamp] NOT NULL,
	[IsAdmin] [bit] NOT NULL,
	[IsApproved] [bit] NOT NULL,
 CONSTRAINT [PK_GroupMembers] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Groups]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Groups](
	[GroupID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL,
	[UpdateDate] [smalldatetime] NOT NULL,
	[MemberCount] [int] NOT NULL CONSTRAINT [DF_Groups_MemberCount]  DEFAULT ((0)),
	[PageName] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Description] [varchar](2000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[AccountID] [int] NOT NULL,
	[Timestamp] [timestamp] NOT NULL,
	[FileID] [bigint] NOT NULL,
	[IsPublic] [bit] NOT NULL,
	[Body] [varchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 CONSTRAINT [PK_Groups] PRIMARY KEY CLUSTERED 
(
	[GroupID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[GroupToGroupTypes]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[GroupToGroupTypes](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[GroupID] [int] NOT NULL,
	[GroupTypeID] [bigint] NOT NULL,
	[Timestamp] [timestamp] NOT NULL,
 CONSTRAINT [PK_GroupToGroupTypes] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[GroupTypes]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[GroupTypes](
	[GroupTypeID] [bigint] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Timestamp] [timestamp] NOT NULL,
 CONSTRAINT [PK_GroupTypes] PRIMARY KEY CLUSTERED 
(
	[GroupTypeID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[LevelOfExperienceTypes]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[LevelOfExperienceTypes](
	[LevelOfExperienceTypeID] [int] IDENTITY(1,1) NOT NULL,
	[LevelOfExperience] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_LevelOfExperience_LevelOfExperience]  DEFAULT (''),
	[Timestamp] [timestamp] NOT NULL,
	[SortOrder] [tinyint] NOT NULL CONSTRAINT [DF_LevelOfExperienceTypes_SortOrder]  DEFAULT ((0)),
 CONSTRAINT [PK_LevelOfExperienceTypes] PRIMARY KEY CLUSTERED 
(
	[LevelOfExperienceTypeID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[MailQueue_History]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[MailQueue_History](
	[MailQueueID] [bigint] IDENTITY(1,1) NOT NULL,
	[SerializedMailMessage] [varchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL,
	[SendDate] [smalldatetime] NOT NULL,
 CONSTRAINT [PK_MailQueue_History] PRIMARY KEY CLUSTERED 
(
	[MailQueueID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[MailQueue_Receiving]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[MailQueue_Receiving](
	[MailQueueID] [bigint] IDENTITY(1,1) NOT NULL,
	[SerializedMailMessage] [varchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL,
	[SendDate] [smalldatetime] NOT NULL,
 CONSTRAINT [PK_MailQueue_Working] PRIMARY KEY CLUSTERED 
(
	[MailQueueID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[MailQueue_Working]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[MailQueue_Working](
	[MailQueueID] [bigint] IDENTITY(1,1) NOT NULL,
	[SerializedMailMessage] [varchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL,
	[SendDate] [smalldatetime] NOT NULL,
 CONSTRAINT [PK_MailQueue_Receiving] PRIMARY KEY CLUSTERED 
(
	[MailQueueID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[MessageFolders]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[MessageFolders](
	[MessageFolderID] [int] IDENTITY(1,1) NOT NULL,
	[FolderName] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[IsSystem] [bit] NOT NULL CONSTRAINT [DF_MessageFolders_IsSystem]  DEFAULT ((0)),
	[Timestamp] [timestamp] NOT NULL,
	[AccountID] [int] NOT NULL CONSTRAINT [DF_MessageFolders_AccountID]  DEFAULT ((0)),
 CONSTRAINT [PK_MessageFolders] PRIMARY KEY CLUSTERED 
(
	[MessageFolderID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[MessageRecipients]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MessageRecipients](
	[MessageRecipientID] [bigint] IDENTITY(1,1) NOT NULL,
	[MessageID] [bigint] NOT NULL,
	[MessageRecipientTypeID] [int] NOT NULL,
	[AccountID] [int] NOT NULL,
	[Timestamp] [timestamp] NOT NULL,
	[MessageFolderID] [int] NOT NULL CONSTRAINT [DF_MessageRecipients_FolderID]  DEFAULT ((0)),
	[MessageStatusTypeID] [int] NOT NULL,
 CONSTRAINT [PK_MessageRecipients] PRIMARY KEY CLUSTERED 
(
	[MessageRecipientID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[MessageRecipientTypes]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[MessageRecipientTypes](
	[MessageRecipientTypeID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 CONSTRAINT [PK_MessageRecipientTypes] PRIMARY KEY CLUSTERED 
(
	[MessageRecipientTypeID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Messages]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Messages](
	[MessageID] [bigint] IDENTITY(1,1) NOT NULL,
	[SentByAccountID] [int] NOT NULL,
	[Subject] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Body] [varchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL CONSTRAINT [DF_Messages_CreateDate]  DEFAULT (getdate()),
	[Timestamp] [timestamp] NOT NULL,
	[MessageTypeID] [int] NOT NULL,
 CONSTRAINT [PK_Messages] PRIMARY KEY CLUSTERED 
(
	[MessageID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[MessageStatusTypes]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[MessageStatusTypes](
	[MessageStatusTypeID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Timestamp] [timestamp] NOT NULL,
 CONSTRAINT [PK_MessageStatusTypes] PRIMARY KEY CLUSTERED 
(
	[MessageStatusTypeID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[MessageTypes]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[MessageTypes](
	[MessageTypeID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](150) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Timestamp] [timestamp] NOT NULL,
 CONSTRAINT [PK_MessageTypes] PRIMARY KEY CLUSTERED 
(
	[MessageTypeID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Moderations]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Moderations](
	[ModerationID] [bigint] IDENTITY(1,1) NOT NULL,
	[AccountID] [int] NULL,
	[AccountUsername] [varchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[SystemObjectID] [int] NOT NULL,
	[SystemObjectRecordID] [bigint] NOT NULL,
	[TimeStamp] [timestamp] NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL CONSTRAINT [DF_Moderations_CreateDate]  DEFAULT (getdate()),
	[IsApproved] [bit] NULL,
	[IsDenied] [bit] NULL,
	[ActionByAccountID] [int] NULL,
	[ActionByUsername] [varchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
 CONSTRAINT [PK_Moderations] PRIMARY KEY CLUSTERED 
(
	[ModerationID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Permissions]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Permissions](
	[PermissionID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Timestamp] [timestamp] NOT NULL,
 CONSTRAINT [PK_Permissions] PRIMARY KEY CLUSTERED 
(
	[PermissionID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[PrivacyFlags]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PrivacyFlags](
	[PrivacyFlagID] [int] IDENTITY(1,1) NOT NULL,
	[PrivacyFlagTypeID] [int] NOT NULL,
	[ProfileID] [int] NOT NULL,
	[VisibilityLevelID] [int] NOT NULL,
	[TimeStamp] [timestamp] NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL CONSTRAINT [DF_PrivacyFlags_CreateDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_PrivacyFlags] PRIMARY KEY CLUSTERED 
(
	[PrivacyFlagID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[PrivacyFlagTypes]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[PrivacyFlagTypes](
	[PrivacyFlagTypeID] [int] IDENTITY(1,1) NOT NULL,
	[FieldName] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[TimeStamp] [timestamp] NOT NULL,
	[SortOrder] [int] NOT NULL CONSTRAINT [DF_PrivacyFlagTypes_SortOrder]  DEFAULT ((0)),
 CONSTRAINT [PK_PrivacyTypes] PRIMARY KEY CLUSTERED 
(
	[PrivacyFlagTypeID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ProfileAttributes]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ProfileAttributes](
	[ProfileAttributeID] [int] IDENTITY(1,1) NOT NULL,
	[ProfileID] [int] NOT NULL,
	[ProfileAttributeTypeID] [int] NOT NULL,
	[Response] [varchar](2000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_ProfileAttributes_Response]  DEFAULT (''),
	[CreateDate] [smalldatetime] NOT NULL CONSTRAINT [DF_ProfileAttributes_CreateDate]  DEFAULT (getdate()),
	[TimeStamp] [timestamp] NOT NULL,
 CONSTRAINT [PK_ProfileAttributes_1] PRIMARY KEY CLUSTERED 
(
	[ProfileAttributeID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ProfileAttributeTypes]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ProfileAttributeTypes](
	[ProfileAttributeTypeID] [int] IDENTITY(1,1) NOT NULL,
	[AttributeType] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[SortOrder] [int] NOT NULL CONSTRAINT [DF_ProfileAttributeTypes_SortOrder]  DEFAULT ((0)),
	[PrivacyFlagTypeID] [int] NOT NULL,
 CONSTRAINT [PK_ProfileAttributes] PRIMARY KEY CLUSTERED 
(
	[ProfileAttributeTypeID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Holds the types of attributes that are available for a profile (about me, how did you get into reef tanks, etc.)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ProfileAttributeTypes', @level2type=N'COLUMN',@level2name=N'ProfileAttributeTypeID'
GO
EXEC sys.sp_addextendedproperty @name=N'Description', @value=N'Holds the types of attributes that are currently available (description, favorite fish, what got you started, etc.)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ProfileAttributeTypes'
GO
/****** Object:  Table [dbo].[Profiles]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Profiles](
	[ProfileID] [int] IDENTITY(1,1) NOT NULL,
	[AccountID] [int] NOT NULL,
	[ProfileName] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[CreateDate] [smalldatetime] NULL,
	[LastUpdateDate] [smalldatetime] NULL,
	[YearOfFirstTank] [int] NOT NULL CONSTRAINT [DF_Profiles_YearOfFirstTank]  DEFAULT ((0)),
	[NumberOfTanksOwned] [int] NOT NULL CONSTRAINT [DF_Profiles_NumberOfTanksOwned]  DEFAULT ((0)),
	[NumberOfFishOwned] [int] NOT NULL CONSTRAINT [DF_Profiles_NumberOfFishOwned]  DEFAULT ((0)),
	[LevelOfExperienceTypeID] [int] NOT NULL CONSTRAINT [DF_Profiles_LevelOfExperienceID]  DEFAULT ((1)),
	[IMMSN] [varchar](40) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_Profiles_IMMSN]  DEFAULT (''),
	[IMAOL] [varchar](40) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_Profiles_IMAOL]  DEFAULT (''),
	[IMGIM] [varchar](40) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_Profiles_IMGIM]  DEFAULT (''),
	[IMYIM] [varchar](40) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_Profiles_IMYIM]  DEFAULT (''),
	[IMICQ] [varchar](40) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_Profiles_IMICQ]  DEFAULT (''),
	[IMSkype] [varchar](40) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_Profiles_IMSkype]  DEFAULT (''),
	[Signature] [varchar](300) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Timestamp] [timestamp] NOT NULL,
	[Avatar] [varbinary](max) NULL,
	[AvatarMimeType] [varchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[UseGravatar] [int] NOT NULL CONSTRAINT [DF_Profiles_UseGravatar]  DEFAULT ((0)),
 CONSTRAINT [PK_Profiles] PRIMARY KEY CLUSTERED 
(
	[ProfileID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Ratings]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Ratings](
	[RatingID] [bigint] IDENTITY(1,1) NOT NULL,
	[Score] [int] NOT NULL,
	[CreatedByUsername] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[CreatedByAccountID] [int] NOT NULL,
	[Timestamp] [timestamp] NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL,
	[SystemObjectID] [int] NOT NULL,
	[SystemObjectRecordID] [bigint] NOT NULL,
	[SystemObjectRatingOptionID] [int] NOT NULL,
 CONSTRAINT [PK_Ratings] PRIMARY KEY CLUSTERED 
(
	[RatingID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[StatusUpdates]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[StatusUpdates](
	[StatusUpdateID] [bigint] IDENTITY(1,1) NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL CONSTRAINT [DF_StatusUpdates_CreateDate]  DEFAULT (getdate()),
	[Status] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[AccountID] [int] NULL,
	[Timestamp] [timestamp] NOT NULL,
 CONSTRAINT [PK_StatusUpdates] PRIMARY KEY CLUSTERED 
(
	[StatusUpdateID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[SystemObjectRatingOptions]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[SystemObjectRatingOptions](
	[SystemObjectRatingOptionID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Description] [varchar](1500) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Timestamp] [timestamp] NOT NULL,
	[SystemObjectID] [int] NOT NULL,
 CONSTRAINT [PK_SystemObjectRatingOptions] PRIMARY KEY CLUSTERED 
(
	[SystemObjectRatingOptionID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[SystemObjects]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[SystemObjects](
	[SystemObjectID] [int] IDENTITY(1,1) NOT NULL,
	[Timestamp] [timestamp] NOT NULL,
	[Name] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 CONSTRAINT [PK_SystemObjects] PRIMARY KEY CLUSTERED 
(
	[SystemObjectID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[SystemObjectTags]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[SystemObjectTags](
	[SystemObjectTagID] [bigint] IDENTITY(1,1) NOT NULL,
	[Timestamp] [timestamp] NOT NULL,
	[TagID] [bigint] NOT NULL,
	[SystemObjectRecordID] [bigint] NOT NULL,
	[SystemObjectID] [int] NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL,
	[CreatedByAccountID] [int] NOT NULL,
	[CreatedByUsername] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 CONSTRAINT [PK_SystemObjectTags] PRIMARY KEY CLUSTERED 
(
	[SystemObjectTagID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Tags]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Tags](
	[TagID] [bigint] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Count] [int] NOT NULL,
	[Timestamp] [timestamp] NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL,
 CONSTRAINT [PK_Tags] PRIMARY KEY CLUSTERED 
(
	[TagID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Terms]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Terms](
	[TermID] [int] IDENTITY(1,1) NOT NULL,
	[Terms] [varchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[CreateDate] [smalldatetime] NOT NULL CONSTRAINT [DF_Terms_CreateDate]  DEFAULT (getdate()),
	[Timestamp] [timestamp] NOT NULL,
 CONSTRAINT [PK_Terms] PRIMARY KEY CLUSTERED 
(
	[TermID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[VisibilityLevels]    Script Date: 06/23/2009 11:40:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[VisibilityLevels](
	[VisibilityLevelID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_VisibilityLevels_VisibilityLevel]  DEFAULT (''),
 CONSTRAINT [PK_VisibilityLevels] PRIMARY KEY CLUSTERED 
(
	[VisibilityLevelID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[AccountFiles]  WITH CHECK ADD  CONSTRAINT [FK_AccountFiles_Accounts] FOREIGN KEY([AccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[AccountFiles] CHECK CONSTRAINT [FK_AccountFiles_Accounts]
GO
ALTER TABLE [dbo].[AccountFiles]  WITH CHECK ADD  CONSTRAINT [FK_AccountFiles_Files] FOREIGN KEY([FileID])
REFERENCES [dbo].[Files] ([FileID])
GO
ALTER TABLE [dbo].[AccountFiles] CHECK CONSTRAINT [FK_AccountFiles_Files]
GO
ALTER TABLE [dbo].[AccountFolders]  WITH CHECK ADD  CONSTRAINT [FK_AccountFolders_Accounts] FOREIGN KEY([AccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[AccountFolders] CHECK CONSTRAINT [FK_AccountFolders_Accounts]
GO
ALTER TABLE [dbo].[AccountFolders]  WITH CHECK ADD  CONSTRAINT [FK_AccountFolders_Folders] FOREIGN KEY([FolderID])
REFERENCES [dbo].[Folders] ([FolderID])
GO
ALTER TABLE [dbo].[AccountFolders] CHECK CONSTRAINT [FK_AccountFolders_Folders]
GO
ALTER TABLE [dbo].[AccountPermissions]  WITH CHECK ADD  CONSTRAINT [FK_AccountPermissions_Accounts] FOREIGN KEY([AccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[AccountPermissions] CHECK CONSTRAINT [FK_AccountPermissions_Accounts]
GO
ALTER TABLE [dbo].[AccountPermissions]  WITH CHECK ADD  CONSTRAINT [FK_AccountPermissions_Permissions] FOREIGN KEY([PermissionID])
REFERENCES [dbo].[Permissions] ([PermissionID])
GO
ALTER TABLE [dbo].[AccountPermissions] CHECK CONSTRAINT [FK_AccountPermissions_Permissions]
GO
ALTER TABLE [dbo].[Accounts]  WITH CHECK ADD  CONSTRAINT [FK_Accounts_Terms] FOREIGN KEY([TermID])
REFERENCES [dbo].[Terms] ([TermID])
GO
ALTER TABLE [dbo].[Accounts] CHECK CONSTRAINT [FK_Accounts_Terms]
GO
ALTER TABLE [dbo].[Alerts]  WITH CHECK ADD  CONSTRAINT [FK_Alerts_Accounts] FOREIGN KEY([AccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[Alerts] CHECK CONSTRAINT [FK_Alerts_Accounts]
GO
ALTER TABLE [dbo].[Alerts]  WITH CHECK ADD  CONSTRAINT [FK_Alerts_AlertTypes] FOREIGN KEY([AlertTypeID])
REFERENCES [dbo].[AlertTypes] ([AlertTypeID])
GO
ALTER TABLE [dbo].[Alerts] CHECK CONSTRAINT [FK_Alerts_AlertTypes]
GO
ALTER TABLE [dbo].[Blogs]  WITH CHECK ADD  CONSTRAINT [FK_Blogs_Accounts] FOREIGN KEY([AccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[Blogs] CHECK CONSTRAINT [FK_Blogs_Accounts]
GO
ALTER TABLE [dbo].[BoardForums]  WITH CHECK ADD  CONSTRAINT [FK_BoardForums_BoardCategorys] FOREIGN KEY([CategoryID])
REFERENCES [dbo].[BoardCategorys] ([CategoryID])
GO
ALTER TABLE [dbo].[BoardForums] CHECK CONSTRAINT [FK_BoardForums_BoardCategorys]
GO
ALTER TABLE [dbo].[BoardPosts]  WITH CHECK ADD  CONSTRAINT [FK_BoardPosts_Accounts] FOREIGN KEY([AccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[BoardPosts] CHECK CONSTRAINT [FK_BoardPosts_Accounts]
GO
ALTER TABLE [dbo].[BoardPosts]  WITH CHECK ADD  CONSTRAINT [FK_BoardPosts_BoardForums] FOREIGN KEY([ForumID])
REFERENCES [dbo].[BoardForums] ([ForumID])
GO
ALTER TABLE [dbo].[BoardPosts] CHECK CONSTRAINT [FK_BoardPosts_BoardForums]
GO
ALTER TABLE [dbo].[BoardPosts]  WITH CHECK ADD  CONSTRAINT [FK_BoardPosts_BoardPosts] FOREIGN KEY([ThreadID])
REFERENCES [dbo].[BoardPosts] ([PostID])
GO
ALTER TABLE [dbo].[BoardPosts] CHECK CONSTRAINT [FK_BoardPosts_BoardPosts]
GO
ALTER TABLE [dbo].[Comments]  WITH CHECK ADD  CONSTRAINT [FK_Comments_Accounts] FOREIGN KEY([CommentByAccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[Comments] CHECK CONSTRAINT [FK_Comments_Accounts]
GO
ALTER TABLE [dbo].[Comments]  WITH CHECK ADD  CONSTRAINT [FK_Comments_SystemObjects] FOREIGN KEY([SystemObjectID])
REFERENCES [dbo].[SystemObjects] ([SystemObjectID])
GO
ALTER TABLE [dbo].[Comments] CHECK CONSTRAINT [FK_Comments_SystemObjects]
GO
ALTER TABLE [dbo].[ContentFilters]  WITH CHECK ADD  CONSTRAINT [FK_ContentFilters_Accounts] FOREIGN KEY([AccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[ContentFilters] CHECK CONSTRAINT [FK_ContentFilters_Accounts]
GO
ALTER TABLE [dbo].[Files]  WITH CHECK ADD  CONSTRAINT [FK_Files_Accounts] FOREIGN KEY([AccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[Files] CHECK CONSTRAINT [FK_Files_Accounts]
GO
ALTER TABLE [dbo].[Files]  WITH CHECK ADD  CONSTRAINT [FK_Files_FileSystemFolders] FOREIGN KEY([FileSystemFolderID])
REFERENCES [dbo].[FileSystemFolders] ([FileSystemFolderID])
GO
ALTER TABLE [dbo].[Files] CHECK CONSTRAINT [FK_Files_FileSystemFolders]
GO
ALTER TABLE [dbo].[Files]  WITH CHECK ADD  CONSTRAINT [FK_Files_FileTypes] FOREIGN KEY([FileTypeID])
REFERENCES [dbo].[FileTypes] ([FileTypeID])
GO
ALTER TABLE [dbo].[Files] CHECK CONSTRAINT [FK_Files_FileTypes]
GO
ALTER TABLE [dbo].[Files]  WITH CHECK ADD  CONSTRAINT [FK_Files_Folders] FOREIGN KEY([DefaultFolderID])
REFERENCES [dbo].[Folders] ([FolderID])
GO
ALTER TABLE [dbo].[Files] CHECK CONSTRAINT [FK_Files_Folders]
GO
ALTER TABLE [dbo].[FolderFiles]  WITH CHECK ADD  CONSTRAINT [FK_FolderFiles_Accounts] FOREIGN KEY([AccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[FolderFiles] CHECK CONSTRAINT [FK_FolderFiles_Accounts]
GO
ALTER TABLE [dbo].[FolderFiles]  WITH CHECK ADD  CONSTRAINT [FK_FolderFiles_Files] FOREIGN KEY([FileID])
REFERENCES [dbo].[Files] ([FileID])
GO
ALTER TABLE [dbo].[FolderFiles] CHECK CONSTRAINT [FK_FolderFiles_Files]
GO
ALTER TABLE [dbo].[FolderFiles]  WITH CHECK ADD  CONSTRAINT [FK_FolderFiles_Folders] FOREIGN KEY([FolderID])
REFERENCES [dbo].[Folders] ([FolderID])
GO
ALTER TABLE [dbo].[FolderFiles] CHECK CONSTRAINT [FK_FolderFiles_Folders]
GO
ALTER TABLE [dbo].[Folders]  WITH CHECK ADD  CONSTRAINT [FK_Folders_Accounts] FOREIGN KEY([AccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[Folders] CHECK CONSTRAINT [FK_Folders_Accounts]
GO
ALTER TABLE [dbo].[Folders]  WITH CHECK ADD  CONSTRAINT [FK_Folders_FolderTypes] FOREIGN KEY([FolderTypeID])
REFERENCES [dbo].[FolderTypes] ([FolderTypeID])
GO
ALTER TABLE [dbo].[Folders] CHECK CONSTRAINT [FK_Folders_FolderTypes]
GO
ALTER TABLE [dbo].[FriendInvitations]  WITH CHECK ADD  CONSTRAINT [FK_FriendInvitations_Accounts] FOREIGN KEY([AccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[FriendInvitations] CHECK CONSTRAINT [FK_FriendInvitations_Accounts]
GO
ALTER TABLE [dbo].[Friends]  WITH CHECK ADD  CONSTRAINT [FK_Friends_Accounts] FOREIGN KEY([AccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[Friends] CHECK CONSTRAINT [FK_Friends_Accounts]
GO
ALTER TABLE [dbo].[Friends]  WITH CHECK ADD  CONSTRAINT [FK_Friends_Accounts1] FOREIGN KEY([MyFriendsAccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[Friends] CHECK CONSTRAINT [FK_Friends_Accounts1]
GO
ALTER TABLE [dbo].[FriendshipDefinitions]  WITH CHECK ADD  CONSTRAINT [FK_FriendshipDefinitions_Friends] FOREIGN KEY([FriendID])
REFERENCES [dbo].[Friends] ([FriendID])
GO
ALTER TABLE [dbo].[FriendshipDefinitions] CHECK CONSTRAINT [FK_FriendshipDefinitions_Friends]
GO
ALTER TABLE [dbo].[FriendshipDefinitions]  WITH CHECK ADD  CONSTRAINT [FK_FriendshipDefinitions_FriendshipDefinitionTypes] FOREIGN KEY([FriendshipDefinitionTypeID])
REFERENCES [dbo].[FriendshipDefinitionTypes] ([FriendshipDefinitionTypeID])
GO
ALTER TABLE [dbo].[FriendshipDefinitions] CHECK CONSTRAINT [FK_FriendshipDefinitions_FriendshipDefinitionTypes]
GO
ALTER TABLE [dbo].[Gags]  WITH CHECK ADD  CONSTRAINT [FK_Gags_Accounts] FOREIGN KEY([AccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[Gags] CHECK CONSTRAINT [FK_Gags_Accounts]
GO
ALTER TABLE [dbo].[Gags]  WITH CHECK ADD  CONSTRAINT [FK_Gags_Accounts1] FOREIGN KEY([GaggedByAccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[Gags] CHECK CONSTRAINT [FK_Gags_Accounts1]
GO
ALTER TABLE [dbo].[GroupForums]  WITH CHECK ADD  CONSTRAINT [FK_GroupForums_BoardForums] FOREIGN KEY([ForumID])
REFERENCES [dbo].[BoardForums] ([ForumID])
GO
ALTER TABLE [dbo].[GroupForums] CHECK CONSTRAINT [FK_GroupForums_BoardForums]
GO
ALTER TABLE [dbo].[GroupForums]  WITH CHECK ADD  CONSTRAINT [FK_GroupForums_Groups] FOREIGN KEY([GroupID])
REFERENCES [dbo].[Groups] ([GroupID])
GO
ALTER TABLE [dbo].[GroupForums] CHECK CONSTRAINT [FK_GroupForums_Groups]
GO
ALTER TABLE [dbo].[GroupMembers]  WITH CHECK ADD  CONSTRAINT [FK_GroupMembers_Accounts] FOREIGN KEY([AccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[GroupMembers] CHECK CONSTRAINT [FK_GroupMembers_Accounts]
GO
ALTER TABLE [dbo].[GroupMembers]  WITH CHECK ADD  CONSTRAINT [FK_GroupMembers_Groups] FOREIGN KEY([GroupID])
REFERENCES [dbo].[Groups] ([GroupID])
GO
ALTER TABLE [dbo].[GroupMembers] CHECK CONSTRAINT [FK_GroupMembers_Groups]
GO
ALTER TABLE [dbo].[Groups]  WITH CHECK ADD  CONSTRAINT [FK_Groups_Accounts] FOREIGN KEY([AccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[Groups] CHECK CONSTRAINT [FK_Groups_Accounts]
GO
ALTER TABLE [dbo].[GroupToGroupTypes]  WITH CHECK ADD  CONSTRAINT [FK_GroupToGroupTypes_Groups] FOREIGN KEY([GroupID])
REFERENCES [dbo].[Groups] ([GroupID])
GO
ALTER TABLE [dbo].[GroupToGroupTypes] CHECK CONSTRAINT [FK_GroupToGroupTypes_Groups]
GO
ALTER TABLE [dbo].[GroupToGroupTypes]  WITH CHECK ADD  CONSTRAINT [FK_GroupToGroupTypes_GroupTypes] FOREIGN KEY([GroupTypeID])
REFERENCES [dbo].[GroupTypes] ([GroupTypeID])
GO
ALTER TABLE [dbo].[GroupToGroupTypes] CHECK CONSTRAINT [FK_GroupToGroupTypes_GroupTypes]
GO
ALTER TABLE [dbo].[MessageRecipients]  WITH CHECK ADD  CONSTRAINT [FK_MessageRecipients_MessageFolders] FOREIGN KEY([MessageFolderID])
REFERENCES [dbo].[MessageFolders] ([MessageFolderID])
GO
ALTER TABLE [dbo].[MessageRecipients] CHECK CONSTRAINT [FK_MessageRecipients_MessageFolders]
GO
ALTER TABLE [dbo].[MessageRecipients]  WITH CHECK ADD  CONSTRAINT [FK_MessageRecipients_MessageRecipientTypes] FOREIGN KEY([MessageRecipientTypeID])
REFERENCES [dbo].[MessageRecipientTypes] ([MessageRecipientTypeID])
GO
ALTER TABLE [dbo].[MessageRecipients] CHECK CONSTRAINT [FK_MessageRecipients_MessageRecipientTypes]
GO
ALTER TABLE [dbo].[MessageRecipients]  WITH CHECK ADD  CONSTRAINT [FK_MessageRecipients_Messages] FOREIGN KEY([MessageID])
REFERENCES [dbo].[Messages] ([MessageID])
GO
ALTER TABLE [dbo].[MessageRecipients] CHECK CONSTRAINT [FK_MessageRecipients_Messages]
GO
ALTER TABLE [dbo].[MessageRecipients]  WITH CHECK ADD  CONSTRAINT [FK_MessageRecipients_MessageStatusTypes] FOREIGN KEY([MessageStatusTypeID])
REFERENCES [dbo].[MessageStatusTypes] ([MessageStatusTypeID])
GO
ALTER TABLE [dbo].[MessageRecipients] CHECK CONSTRAINT [FK_MessageRecipients_MessageStatusTypes]
GO
ALTER TABLE [dbo].[Messages]  WITH CHECK ADD  CONSTRAINT [FK_Messages_Accounts] FOREIGN KEY([SentByAccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[Messages] CHECK CONSTRAINT [FK_Messages_Accounts]
GO
ALTER TABLE [dbo].[Messages]  WITH CHECK ADD  CONSTRAINT [FK_Messages_MessageTypes] FOREIGN KEY([MessageTypeID])
REFERENCES [dbo].[MessageTypes] ([MessageTypeID])
GO
ALTER TABLE [dbo].[Messages] CHECK CONSTRAINT [FK_Messages_MessageTypes]
GO
ALTER TABLE [dbo].[Moderations]  WITH CHECK ADD  CONSTRAINT [FK_Moderations_Accounts] FOREIGN KEY([AccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[Moderations] CHECK CONSTRAINT [FK_Moderations_Accounts]
GO
ALTER TABLE [dbo].[Moderations]  WITH CHECK ADD  CONSTRAINT [FK_Moderations_SystemObjects] FOREIGN KEY([SystemObjectID])
REFERENCES [dbo].[SystemObjects] ([SystemObjectID])
GO
ALTER TABLE [dbo].[Moderations] CHECK CONSTRAINT [FK_Moderations_SystemObjects]
GO
ALTER TABLE [dbo].[PrivacyFlags]  WITH CHECK ADD  CONSTRAINT [FK_PrivacyFlags_PrivacyFlagTypes] FOREIGN KEY([PrivacyFlagTypeID])
REFERENCES [dbo].[PrivacyFlagTypes] ([PrivacyFlagTypeID])
GO
ALTER TABLE [dbo].[PrivacyFlags] CHECK CONSTRAINT [FK_PrivacyFlags_PrivacyFlagTypes]
GO
ALTER TABLE [dbo].[PrivacyFlags]  WITH CHECK ADD  CONSTRAINT [FK_PrivacyFlags_Profiles] FOREIGN KEY([ProfileID])
REFERENCES [dbo].[Profiles] ([ProfileID])
GO
ALTER TABLE [dbo].[PrivacyFlags] CHECK CONSTRAINT [FK_PrivacyFlags_Profiles]
GO
ALTER TABLE [dbo].[PrivacyFlags]  WITH CHECK ADD  CONSTRAINT [FK_PrivacyFlags_VisibilityLevels] FOREIGN KEY([VisibilityLevelID])
REFERENCES [dbo].[VisibilityLevels] ([VisibilityLevelID])
GO
ALTER TABLE [dbo].[PrivacyFlags] CHECK CONSTRAINT [FK_PrivacyFlags_VisibilityLevels]
GO
ALTER TABLE [dbo].[ProfileAttributes]  WITH CHECK ADD  CONSTRAINT [FK_ProfileAttributes_ProfileAttributeTypes] FOREIGN KEY([ProfileAttributeTypeID])
REFERENCES [dbo].[ProfileAttributeTypes] ([ProfileAttributeTypeID])
GO
ALTER TABLE [dbo].[ProfileAttributes] CHECK CONSTRAINT [FK_ProfileAttributes_ProfileAttributeTypes]
GO
ALTER TABLE [dbo].[ProfileAttributes]  WITH CHECK ADD  CONSTRAINT [FK_ProfileAttributes_Profiles] FOREIGN KEY([ProfileID])
REFERENCES [dbo].[Profiles] ([ProfileID])
GO
ALTER TABLE [dbo].[ProfileAttributes] CHECK CONSTRAINT [FK_ProfileAttributes_Profiles]
GO
ALTER TABLE [dbo].[Profiles]  WITH CHECK ADD  CONSTRAINT [FK_Profiles_Accounts] FOREIGN KEY([AccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[Profiles] CHECK CONSTRAINT [FK_Profiles_Accounts]
GO
ALTER TABLE [dbo].[Profiles]  WITH CHECK ADD  CONSTRAINT [FK_Profiles_LevelOfExperienceTypes] FOREIGN KEY([LevelOfExperienceTypeID])
REFERENCES [dbo].[LevelOfExperienceTypes] ([LevelOfExperienceTypeID])
GO
ALTER TABLE [dbo].[Profiles] CHECK CONSTRAINT [FK_Profiles_LevelOfExperienceTypes]
GO
ALTER TABLE [dbo].[Ratings]  WITH CHECK ADD  CONSTRAINT [FK_Ratings_Accounts] FOREIGN KEY([CreatedByAccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[Ratings] CHECK CONSTRAINT [FK_Ratings_Accounts]
GO
ALTER TABLE [dbo].[Ratings]  WITH CHECK ADD  CONSTRAINT [FK_Ratings_SystemObjectRatingOptions] FOREIGN KEY([SystemObjectRatingOptionID])
REFERENCES [dbo].[SystemObjectRatingOptions] ([SystemObjectRatingOptionID])
GO
ALTER TABLE [dbo].[Ratings] CHECK CONSTRAINT [FK_Ratings_SystemObjectRatingOptions]
GO
ALTER TABLE [dbo].[Ratings]  WITH CHECK ADD  CONSTRAINT [FK_Ratings_SystemObjects] FOREIGN KEY([SystemObjectID])
REFERENCES [dbo].[SystemObjects] ([SystemObjectID])
GO
ALTER TABLE [dbo].[Ratings] CHECK CONSTRAINT [FK_Ratings_SystemObjects]
GO
ALTER TABLE [dbo].[StatusUpdates]  WITH CHECK ADD  CONSTRAINT [FK_StatusUpdates_Accounts] FOREIGN KEY([AccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[StatusUpdates] CHECK CONSTRAINT [FK_StatusUpdates_Accounts]
GO
ALTER TABLE [dbo].[SystemObjectRatingOptions]  WITH CHECK ADD  CONSTRAINT [FK_SystemObjectRatingOptions_SystemObjects] FOREIGN KEY([SystemObjectID])
REFERENCES [dbo].[SystemObjects] ([SystemObjectID])
GO
ALTER TABLE [dbo].[SystemObjectRatingOptions] CHECK CONSTRAINT [FK_SystemObjectRatingOptions_SystemObjects]
GO
ALTER TABLE [dbo].[SystemObjectTags]  WITH CHECK ADD  CONSTRAINT [FK_SystemObjectTags_Accounts] FOREIGN KEY([CreatedByAccountID])
REFERENCES [dbo].[Accounts] ([AccountID])
GO
ALTER TABLE [dbo].[SystemObjectTags] CHECK CONSTRAINT [FK_SystemObjectTags_Accounts]
GO
ALTER TABLE [dbo].[SystemObjectTags]  WITH CHECK ADD  CONSTRAINT [FK_SystemObjectTags_SystemObjects] FOREIGN KEY([SystemObjectID])
REFERENCES [dbo].[SystemObjects] ([SystemObjectID])
GO
ALTER TABLE [dbo].[SystemObjectTags] CHECK CONSTRAINT [FK_SystemObjectTags_SystemObjects]
GO
ALTER TABLE [dbo].[SystemObjectTags]  WITH CHECK ADD  CONSTRAINT [FK_SystemObjectTags_Tags] FOREIGN KEY([TagID])
REFERENCES [dbo].[Tags] ([TagID])
GO
ALTER TABLE [dbo].[SystemObjectTags] CHECK CONSTRAINT [FK_SystemObjectTags_Tags]







USE [Fisharoo]
GO
/****** Object:  StoredProcedure [dbo].[pr_MailQueue_MoveWorkingToHistory]    Script Date: 06/23/2009 11:44:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create procedure [dbo].[pr_MailQueue_MoveWorkingToHistory]

as

begin tran

insert into MailQueue_History (SerializedMailMessage, CreateDate, SendDate)
(select SerializedMailMessage, CreateDate, GetDate() from MailQueue_Working)

truncate table MailQueue_Working

commit
GO
/****** Object:  StoredProcedure [dbo].[pr_MailQueue_SwapReceivingAndWorking_GetWorking]    Script Date: 06/23/2009 11:44:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
execute pr_MailQueue_SwapReceivingAndWorking_GetWorking
*/

CREATE procedure [dbo].[pr_MailQueue_SwapReceivingAndWorking_GetWorking]

as

begin tran

--rename working to temp
execute sp_rename
	@objname = 'MailQueue_Working',
	@newname = 'MailQueue_Temp'

--rename receiving to working
execute sp_rename
	@objname = 'MailQueue_Receiving',
	@newname = 'MailQueue_Working'

--rename temp to receiving
execute sp_rename
	@objname = 'MailQueue_Temp',
	@newname = 'MailQueue_Receiving'

select * from MailQueue_Working

commit tran





USE [Fisharoo]
GO
/****** Object:  UserDefinedFunction [dbo].[IsFlagged]    Script Date: 06/23/2009 11:45:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create function [dbo].[IsFlagged]
(
	@SystemObjectID int,
	@SystemObjectRecordID bigint
)
returns bit 

as
begin
	declare @result bit
	if exists (
		select 1 
		from moderations 
		where systemobjectid = @SystemObjectID and 
			systemobjectrecordid = @SystemObjectRecordID and 
			isdenied = 'true')
	begin
		set @result = 1
	end
	else
	begin
		set @result = 0
	end

	return @result
end

